package com.esm.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.esm.service.UserService;
import com.esm.serviceimpl.UserServiceImpl;
import com.esm.utils.PrintWriterUtil;

import net.sf.json.JSONObject;

/**
 * DeleteEmployeeController
 * 删除员工信息控制者
 * @author 魏长均
 *
 */
public class DeleteEmployeeController_wcj extends HttpServlet
{
	private static final long serialVersionUID = 1L;
	UserService uService = new UserServiceImpl();
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException 
	{
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException 
	{
		int uid = Integer.parseInt(req.getParameter("uid"));
		boolean flag = uService.deleteEmployee(uid);
		PrintWriter pw = resp.getWriter();
		JSONObject jo = new JSONObject();
		jo.put("flag", flag);
		PrintWriterUtil.flushJoAndClosePrintWriter(pw, jo);
	}
	
}
